const Controller=qguan("Controller")

/**
 * web端依赖
 */
@Controller("/jsr")
export default  class JsrCtrl{
    constructor(){
        this.root=  qguan("root");
    }
    //用户登录
    @Controller("/")
    find(req,res,url){
        res.setHeader("Content-Type", "application/x-javascript");
        res.setHeader("Content-Disposition", "attachment; filename="+url.query.name);
        res.setHeader("Access-Control-Allow-Origin", "*");
        let _this=this;
        let _name= url.pathname.substring(url.pathname.lastIndexOf("/")+1);

        try{
            //  this.userService.add();
            let data=this.root.findData(_name)

            data.then(   (data1)=>{
                res.write(data1)
                res.end();
            } )


        }catch (e) {
            res.write({
                message: '异常'
            })
            res.end();
            return;
        }

    }



}
